import java.util.*;
class a2{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int size=in.nextInt();
        int[] ar=new int[size];
        for(int i=0;i<size;i++){
            ar[i]=in.nextInt();
        }
        int[] copyarr=Arrays.copyOf(ar,size);
        Arrays.sort(copyarr);
        boolean[] haspostion=new boolean[size];
        int k=in.nextInt();
        for(int i=0;i<k;i++){
            int item1=in.nextInt()-1;
            int item2=in.nextInt()-1;
            haspostion[item1]=true;
            haspostion[item2]=true;
        }
        int a=0;
        for(int i=0;i<size;i++){
            if(copyarr[i]!=ar[i]&&haspostion[i]==false){
                a++;
            }
        }
        if(a==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
            System.out.println(a-1);
        }
    }
}